package com.cn.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cn.busi.StuController;
import com.cn.mapper.StuMapper;
import com.cn.mapper.UserMapper;
import com.cn.model.Stu;
import com.cn.model.User;
import com.cn.service.exception.ErrorCode;


@Service
public class StuService {
	

	/**
	 * 日志
	 */
	private Logger logger = LoggerFactory.getLogger(StuController.class);
	
	@Autowired
	private StuMapper stuMapper;
	/**
	 * 添加新用户
	 * 
	 * @param 
	 * @return
	 */
	
	
	public void addStu(Stu stu) {
		
		stuMapper.addStu(stu);
	}
	
	/**
	 * 删除
	 * 
	 * @param 
	 * @return
	 */
	public void delStu(String id,String name) {
		
		Map<String, String> csmapMap = new HashMap<String, String>();
		csmapMap.put("id",id);
		csmapMap.put("name",name);
		
		stuMapper.delStu(csmapMap);
	}
	
	/**
	 * 更新学生信息
	 * 
	 * @param 
	 * @return
	 */
	public void updateStu(Stu stu) {
		Map map = new  HashMap();
		map.put("id", stu.getId());
		map.put("name", stu.getName());
		map.put("age", stu.getAge());
		logger.debug(map.toString());
		stuMapper.updataStu(map);
	}
	
	/**
	 * 查询所有学生
	 * 
	 * @param 
	 * @return
	 */
	public List<Stu> getStu1() {
		
	
		
		return stuMapper.getStu();
	}

}
